package com.fruit.auth.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import com.alibaba.fastjson.annotation.JSONField;

import lombok.Getter;
import lombok.Setter;

@Entity
@Table(name="AUTH_ROLE")
@Setter
@Getter
public class Role implements Serializable
{
	public static final String ROLE_ADMIN="ROLE_ADMIN";
	private static final long serialVersionUID = -4178728040719513331L;
	
	//角色ID
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	//角色名称
	@JSONField(name="text")
	@Column(length=64)
	private String name;
	
	//角色描述
	private String description;

	//是否启用该角色，默认启用,被禁用的角色不参与权限控制
	private Boolean roleEnabled=Boolean.TRUE;
	
	//角色代码
	private String roleCode;


	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Role other = (Role) obj;
		
		if (id == null)
		{
			if (other.id != null)
				return false;
		}
		else if (!id.equals(other.id))
			return false;
		return true;
	}


	public Role(Integer id, String name)
	{
		this.id = id;
		this.name = name;
	}


	public Role()
	{
	}
	
	
}
